<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "user_group".
 *
 * @property integer $group_id
 * @property string $group_name
 * @property integer $created_at
 * @property integer $updated_at
 */
class UserGroup extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_group';
    }
    
    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
        ];
    }
    
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['group_name'], 'required'],
            [['created_at', 'updated_at'], 'integer'],
            [['group_name'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'group_id' => '排序',
            'group_name' => '用户人群',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
        ];
    }
    
    /**
     * 返回所有人群数组
     * @return array|UserGroup[]|\yii\db\ActiveRecord[]
     */
    public static function findList()
    {
        return static::find()->asArray()->all();
    }
}
